package com.cesgroup.zw.spring.boot.library.echarts.barAndScatter.complex;

import com.cesgroup.zw.spring.boot.echarts.component.series.Scatter;
import com.cesgroup.zw.spring.boot.echarts.model.style.ItemStyle;

import java.util.Arrays;

/**
 * @author ytj
 * @date 2019/7/5 13:52
 */
public class ComplexScatterSeries extends Scatter {
    public ComplexScatterSeries(ComplexBarAndScatterParam param){
        this.setName("外圆");
        this.setType("scatter");
        this.setHoverAnimation(false);
        this.setData((Object[]) param.getDataset().get("circular"));
        this.setYAxisIndex(2);
        this.setSymbolSize(35);
        this.setItemStyle(new ItemStyle(){{
            Object[] obj=(Object[]) param.getDataset().get("color");
            StringBuffer sbf=new StringBuffer();
            sbf.append("[");
            Arrays.stream(obj).forEach(e->sbf.append("'"+e+"',"));
            sbf.append("]");
            this.setColor("function(params) {var myColor="+sbf+" ;var num = myColor.length;return myColor[params.dataIndex % num]}");
            this.setOpacity(1);
        }});
        this.setZ(2);
    }
}
